<template>
    <header>
        <div class="container">
            <ul>
                <li v-if="$store.state.userInfor.userName">{{$store.state.userInfor.userName}}</li>
                <router-link to="/login" tag="li" v-else>请先登录</router-link>
                <li v-if="$store.state.userInfor.userName" @click="logout">退出登录</li>
                <li v-else>免费注册</li>
                <li>我的订单</li>
                <li>会员中心</li>
                <li>帮助中信</li>
                <li>关于我们</li>
                <li>手机版</li>
            </ul>
        </div>
    </header>
</template>

<script>
export default {
    data() {
        return {
            uname:''
        }
    },
    methods: {
        logout(){
            this.$store.commit('clearUserInfor')
            this.$router.push('/login')
        },
    },
}
</script>

<style lang="scss" scoped>
header {
    height: 53px;
    background: #333;

    ul {
        display: flex;
        height: 53px;
        justify-content: flex-end;
        align-items: center;

        li {
            position: relative;
            padding: 0 15px;
            color: #cdcdcd;
            line-height: 1;
            display: inline-block;

            &:hover {
                color: #27ba9b;
            }

            &::after {
                content: '';
                position: absolute;
                right: 0;
                top: 0;
                width: 2px;
                height: 100%;
                background: #ccc;
            }
        }
    }
}
</style>